<?php
class Invite_model extends CI_Model {
	function __construct()
    {
        parent::__construct();
    }
	public function is_invited($target_id, $target_type, $user_id) {
		$sql = "select count(*) as total from invites 
		where target_type=" . $this->db->escape($target_type) . " and target_id=" . $target_id . " and user_id=" . intval($user_id);
		$result= $this->db->query($sql)->row_array();
		return $result['total'];
	}

	
	public function add($data) {   
		$this->db->insert("invites", $data);
		return $this->db->insert_id();
	}
}